package com.huiw.archives.modules.job.service;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.huiw.archives.modules.sys.service.WisArchivesTaskService;

/**
 * 
 * @author yangc
 *
 */
@Component
public class WisArchivesTaskJob {

	/**
	 * 任务
	 */
	@Autowired
	WisArchivesTaskService wisArchivesTaskService;

	/**
	 * 
	 * yangc 2017年11月23日 下午12:17:30
	 * <p>
	 * Title: lessFive
	 * </p>
	 * <p>
	 * Description: 办结时间不足5天
	 * </p>
	 * 
	 * @throws Exception
	 */
	public void lessFive() {
		SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
		Calendar date = Calendar.getInstance();
		Date nowDate = new Date();
		date.setTime(nowDate);
		String nowDateStr = dft.format(date.getTime());
		date.set(Calendar.DATE, date.get(Calendar.DATE) - 5);
		String lessFiveDateStr = dft.format(date.getTime());

		String hql = "FROM WisArchivesTask WHERE taskDealTimeEnd >='" + lessFiveDateStr +"' and taskDealTimeEnd <='" + nowDateStr + "' and taskStatus<" + 4;
		List<Object> list;
		try {
			list = wisArchivesTaskService.queryByHql(hql);
			System.out.println("****************lessFive=" + list.size());
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	/**
	 * yangc 2017年11月23日 下午12:26:58
	 * <p>
	 * Title: overTime
	 * </p>
	 * <p>
	 * Description: 已超期件数
	 * </p>
	 */
	public void overTime() {
		SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
		Calendar date = Calendar.getInstance();
		String nowDateStr = dft.format(date.getTime());

		String hql = "FROM WisArchivesTask WHERE taskDealTimeEnd >='" + nowDateStr + "' and taskStatus<" + 4;
		List<Object> list;
		try {
			list = wisArchivesTaskService.queryByHql(hql);
			System.out.println("****************overTime=" + list.size());
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
